﻿using ReservationModule.Classes;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ReservationModule
{
    public partial class StaffCreation : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["Login"] = Session["Login"];
            if (Session["Login"] == "false" || Session["Login"] == null)
            {
                Response.Redirect("Reject.aspx");
            }

            if (Session["StaffType"] == "Receptionist")
            {
                Response.Redirect("Reject.aspx");
            }
        }

        protected void btnCreate_Click(object sender, EventArgs e)
        {
            string staffNRIC = tbxStaffNRIC.Text;
            string staffName = tbxStaffName.Text;
            string staffType = DDLStaffType.Text;
            DateTime dateOfBirth = Convert.ToDateTime(tbxDOB.Text);
            string nationality = tbxNationality.Text;
            string contactNumber = tbxContactNumber.Text;
            string bankAccountNumber = tbxBankNo.Text;
            string dutyType = DDLDutyType.Text;

            Staff s = new Staff() { StaffNRIC1 = staffNRIC, StaffName1 = staffName, StaffType1 = staffType, DateOfBirth1 = dateOfBirth, Nationality1 = nationality, ContactNumber1 = contactNumber, BankAccountNumber1 = bankAccountNumber, DutyType1 = dutyType };
            int staff = DBManager.CreateStaff(s);

            if (staff == 1)
            {
                Response.Redirect("StaffCreationSuccessful.aspx");
            }
            else
            {
                Label1.Text = "StaffNRIC already exist";
            }

        }

        protected void btnBack_Click(object sender, EventArgs e)
        {
            Response.Redirect("HousekeepingAndStaffMenu.aspx");
        }


    }
}